package com.ruoyi.project.lesson.lessonad.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.lesson.lessonad.domain.LessonAd;
import com.ruoyi.project.lesson.lessonad.mapper.LessonAdMapper;
import com.ruoyi.project.lesson.lessonad.service.ILessonAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 推广位置Service业务层处理
 *
 * @author shixiangwen
 * @date 2020-12-22
 */
@Service
@DataSource(DataSourceType.KKFORMULA)
public class LessonAdServiceImpl implements ILessonAdService {

    @Autowired
    private LessonAdMapper lessonAdMapper;

    /**
     * 查询推广位置
     *
     * @param id 推广位置ID
     * @return 推广位置
     */
    @Override
    public LessonAd selectLessonAdById(Long id) {
        return lessonAdMapper.selectLessonAdById(id);
    }

    /**
     * 查询推广位置列表
     *
     * @param lessonAd 推广位置
     * @return 推广位置
     */
    @Override
    public List<LessonAd> selectLessonAdList(LessonAd lessonAd) {
        return lessonAdMapper.selectLessonAdList(lessonAd);
    }

    /**
     * 新增推广位置
     *
     * @param lessonAd 推广位置
     * @return 结果
     */
    @Override
    public int insertLessonAd(LessonAd lessonAd) {
        lessonAd.setCreatedTime(DateUtils.getNowDate());
        return lessonAdMapper.insertLessonAd(lessonAd);
    }

    /**
     * 修改推广位置
     *
     * @param lessonAd 推广位置
     * @return 结果
     */
    @Override
    public int updateLessonAd(LessonAd lessonAd) {
        return lessonAdMapper.updateLessonAd(lessonAd);
    }

    /**
     * 删除推广位置对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLessonAdByIds(String ids) {
        return lessonAdMapper.deleteLessonAdByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除推广位置信息
     *
     * @param id 推广位置ID
     * @return 结果
     */
    @Override
    public int deleteLessonAdById(Long id) {
        return lessonAdMapper.deleteLessonAdById(id);
    }
}
